chore: replace utopia-php/framework with standalone packages#837
chore: replace utopia-php/framework with standalone packages#837
Conversation
…opia-php/console Remove the heavy framework dependency in favor of the lightweight standalone packages that this library actually uses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughUpdated dependencies and Console import namespaces; narrowed tenant types to strings and added per-document tenant extraction/propagation and validation in shared-table database flows. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Database
participant Adapter
participant Document
Client->>Database: createDocument(document)
Note right of Database: Shared Tables + Tenant-per-Document
Database->>Document: extract tenant from document (doc->getTenant())
alt tenant is null and required
Database-->>Client: throw missing tenant error
else tenant present
Database->>Document: set internal '$tenant' field (string)
Database->>Adapter: setTenant(string tenant)
Database->>Adapter: persist document (with '$tenant')
Adapter-->>Database: persist result
Database-->>Client: return created document
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CLI 0.22 no longer depends on utopia-php/framework, removing it from the dependency tree entirely. Console moved to the standalone utopia-php/console package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
setTenant() accepts int|string|null but PDO returns tenant as a string after storage. The strict !== comparisons in getCollection() then fail because (int)1 !== "1", causing "Collection not found" errors. The Sequence validator also rejects integer tenant values since $tenant has type VAR_ID which requires strings. Cast tenant to string in Adapter::setTenant(), Document::getTenant(), and the tenantPerDocument document paths. Skip Sequence validation for $tenant since it's a user-provided identifier, not a sequence-generated ID. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ac7da4f to
a0b48ed
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Database/Document.php`:
- Around line 175-183: Update the docblock for the getTenant method to match its
native signature: change the `@return` annotation from "int|string|null" to
"string|null" so the PHPDoc aligns with the native return type declared on the
getTenant() method.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 128641c6-7a0d-4997-99bb-47a0e483f2e0
📒 Files selected for processing (4)
src/Database/Adapter.phpsrc/Database/Database.phpsrc/Database/Document.phpsrc/Database/Validator/Structure.php
🚧 Files skipped from review as they are similar to previous changes (2)
- src/Database/Adapter.php
- src/Database/Database.php
| /** | ||
| * @return int|string|null | ||
| */ | ||
| public function getTenant(): int|string|null | ||
| public function getTenant(): string|null | ||
| { | ||
| return $this->getAttribute('$tenant'); | ||
| $tenant = $this->getAttribute('$tenant'); | ||
|
|
||
| return $tenant !== null ? (string) $tenant : null; | ||
| } |
There was a problem hiding this comment.
Fix the docblock return type to match the native return type.
The docblock at line 175-177 declares @return int|string|null, but the native return type on line 178 is string|null. This mismatch is causing the PHPStan CI failure.
🐛 Proposed fix
/**
- * `@return` int|string|null
+ * `@return` string|null
*/
public function getTenant(): string|null📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * @return int|string|null | |
| */ | |
| public function getTenant(): int|string|null | |
| public function getTenant(): string|null | |
| { | |
| return $this->getAttribute('$tenant'); | |
| $tenant = $this->getAttribute('$tenant'); | |
| return $tenant !== null ? (string) $tenant : null; | |
| } | |
| /** | |
| * `@return` string|null | |
| */ | |
| public function getTenant(): string|null | |
| { | |
| $tenant = $this->getAttribute('$tenant'); | |
| return $tenant !== null ? (string) $tenant : null; | |
| } |
🧰 Tools
🪛 GitHub Actions: CodeQL
[error] 178-178: PHPStan: @return tag has incompatible type 'int|string|null' with native return type 'string|null' in PHPDoc. Found 1 error. Command './vendor/bin/phpstan analyse --level 7 src tests --memory-limit 2G' failed with exit code 1.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Database/Document.php` around lines 175 - 183, Update the docblock for
the getTenant method to match its native signature: change the `@return`
annotation from "int|string|null" to "string|null" so the PHPDoc aligns with the
native return type declared on the getTenant() method.
Summary
utopia-php/frameworkdependency withutopia-php/validators(0.2.) andutopia-php/console(0.1.) — the only parts of the framework this library actually usesUtopia\CLI\Consoleimports toUtopia\Consolein src and testsTest plan
composer installresolves dependencies correctlybin/CLI scripts still work (they useutopia-php/clifrom dev dependencies)🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Bug Fixes
Maintenance